package com.py.pythink;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@SpringBootApplication
@MapperScan("com.py.pythink.dao") //识别Mybatis的dao
@EnableTransactionManagement //让事务生效
public class PythinkApplication {

    public static void main(String[] args) {
        SpringApplication.run(PythinkApplication.class, args);
    }
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        //1.实例化分页拦截器
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //2.设置数据库的类型
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        //3.返回
        return interceptor;

    }

}
